/****** Object:  StoredProcedure [dbo].[cleartables]    Script Date: 11/26/2011 16:38:32 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cleartables]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[cleartables]
GO




-- ================================================
-- Template generated from Template Explorer using:
-- Create Procedure (New Menu).SQL
--
-- Use the Specify Values for Template Parameters 
-- command (Ctrl-Shift-M) to fill in the parameter 
-- values below.
--
-- This block of comments will not be included in
-- the definition of the procedure.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE cleartables
	-- Add the parameters for the stored procedure here
	--<@Param1, sysname, @p1> <Datatype_For_Param1, , int> = <Default_Value_For_Param1, , 0>, 
	--<@Param2, sysname, @p2> <Datatype_For_Param2, , int> = <Default_Value_For_Param2, , 0>
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here

ALTER TABLE [dbo].[Actors_Index] DROP CONSTRAINT [FK_Actors_Index_Actors_Names]
ALTER TABLE [dbo].[Directors_Index] DROP CONSTRAINT [FK_Directors_Index_Directors_Names]
ALTER TABLE [dbo].[Directors_Index] DROP CONSTRAINT [FK_Directors_Index_DVD]
ALTER TABLE [dbo].[Actors_Index] DROP CONSTRAINT [FK_Actors_Index_DVD]


truncate table DVD
truncate table Actors_Index
truncate table Directors_Index
truncate table Actors_Names
truncate table Directors_Names


ALTER TABLE [dbo].[Actors_Index]  WITH NOCHECK ADD  CONSTRAINT [FK_Actors_Index_Actors_Names] FOREIGN KEY([Actor_ID])
REFERENCES [dbo].[Actors_Names] ([Actor_ID])

ALTER TABLE [dbo].[Actors_Index] CHECK CONSTRAINT [FK_Actors_Index_Actors_Names]

ALTER TABLE [dbo].[Directors_Index]  WITH NOCHECK ADD  CONSTRAINT [FK_Directors_Index_Directors_Names] FOREIGN KEY([Director_ID])
REFERENCES [dbo].[Directors_Names] ([Director_ID])

ALTER TABLE [dbo].[Directors_Index] CHECK CONSTRAINT [FK_Directors_Index_Directors_Names]

ALTER TABLE [dbo].[Actors_Index]  WITH NOCHECK ADD  CONSTRAINT [FK_Actors_Index_DVD] FOREIGN KEY([DVDList_id])
REFERENCES [dbo].[DVD] ([ID])

ALTER TABLE [dbo].[Actors_Index] CHECK CONSTRAINT [FK_Actors_Index_DVD]

ALTER TABLE [dbo].[Directors_Index]  WITH NOCHECK ADD  CONSTRAINT [FK_Directors_Index_DVD] FOREIGN KEY([DVDList_ID])
REFERENCES [dbo].[DVD] ([ID])

ALTER TABLE [dbo].[Directors_Index] CHECK CONSTRAINT [FK_Directors_Index_DVD]


END
GO




